package gamagora.game.entity
{
	import gamagora.game.resources.OSImages;
	import gamagora.game.resources.OSSounds;

	public class OSHouse extends OSEntity
	{
		private var _background:OSEntity;
		private var _play:Boolean;
		
		//0xfffbe12d
		public function OSHouse(X:Number=0, Y:Number=0)
		{
			super(NOTHING, X, Y, OSImages.HOUSE);
			offset.x = 30;
			offset.y = 46;
			
			//Background
			_background = new OSEntity(NOTHING, X + 134, Y + 76);
			_background.makeGraphic(176, 130, 0xfffbe12d);
			
			//Walls
			add(new OSGround(X + 50, Y + 10, 346, 20));
			add(new OSGround(X + 50, Y + 30, 20, 100, 0, false, false));
			add(new OSGround(X + 376, Y + 30, 20, 100, 0, false, false));
		}
		
		//Getters Setters

		public function get background():OSEntity
		{
			return _background;
		}
		
		//Override
		
		public override function update():void
		{
			super.update();
			
			if(_world.getPlayerX() > x + 50 && _world.getPlayerX() < x + 376 && !_play)
			{
				OSSounds.playHouse(0.2);
				_play = true;
			}
			
			if(_world.getPlayerX() < x + 50 || _world.getPlayerX() > x + 376)
			{
					_play = false;
			}

		}

	}
}
